<?php
//20090213
//store in db??

//200902102224
//implement me!!!!





$red 		= array ("txt_red"		,"#800000","#ffcccc","#cc6666");
$yellow	= array ("txt_yellow"	,"#808000","#ffffcc","#cccc66");
$green	= array ("txt_green"	,"#008000","#ccffcc","#66cc66");
$cyan		= array ("txt_cyan"		,"#008080","#ccffff","#66cccc");
$blue		= array ("txt_blue"		,"#000080","#ccccff","#6666cc");
$purple	= array ("txt_purple"	,"#800080","#ffccff","#cc66cc");

$themes = array ($red,$yellow,$green,$cyan,$blue,$purple);

if ($id) {
	$query = "select * from `usertheme` where `user`='$id'";
	$result = mysql_query($query);
	if (mysql_num_rows($result)){
		$usertheme = mysql_fetch_array($result);
		$userdefined = array ("txt_usertheme", $usertheme['colour1'],$usertheme['colour2'],$usertheme['colour3']);
		$themes = array ($userdefined,$red,$yellow,$green,$cyan,$blue,$purple);	
	}
} 





if ($_REQUEST['theme']) {
	if ($_POST['theme']) {
		$mytheme = escapestr ($_POST['theme']);
		setcookie("theme",$mytheme, time()+2500000);
		if ($id) {
			$query = "update `users` set `theme`='$mytheme' where `id`='$id'";
			$result = mysql_query($query);
		}
	}
	else 	$mytheme = escapestr ($_REQUEST['theme']);
}	

if ($id) {
	$query = "select `theme` from `users` where `id`='$id'";
	$result = mysql_query($query);
	$mytheme = mysql_result($result,0);
}


if (!($mytheme)) $mytheme = "txt_blue";
$SITE_THEME = "<form action=\"index.php\" method=\"post\"><select name=\"theme\" size=\"1\">";
foreach ($themes as $theme) {
	$SITE_THEME .= "<option ";
	if ($theme[0] == $mytheme) {
		$SITE_THEME .= " selected ";	
		$colour1	=	$theme[1]; 
		$colour2	=	$theme[2];
		$colour3	=	$theme[3];
	}
	$SITE_THEME .= "value=\"$theme[0]\">".GetLangString($lang,$theme[0])."</option> ";
}
$SITE_THEME .="</select><br><input type=\"submit\" value=\"".GetLangString($lang,"txt_changetheme")."\"></form>";


$CSS = ".profileelement {
	background-color: $colour3;
}

#topbox, #right, #middle, #mobile  {
	border: 3px dashed $colour1; 
}

.artthumb, .photothumb, .djthumb, .userthumb , .usersmallthumb, .userextrasmallthumb {
	border: 1px dashed $color1; 
}

#login a:hover, #rightbox a:hover, .label, .smalllabel, .nav a:hover, .artthumb:hover, .djthumb:hover, .photothumb:hover, .userthumb:hover, 
.usersmallthumb:hover, .userextrasmallthumb:hover,.forumelement:hover, body
{
  	background-color: $colour3; 
	color: $colour2; 
}



#login a, #login a, #rightbox a,  #hosted, #rightbox, #topbox, #right, #middle, .forumelement, .nav, .nav a, .artthumb, .djthumb, 
.photothumb, .userthumb, .forumelement, #mobile , #middle, #middle table .element, #middle table table, #mobile table
 {
	color: $colour3;
	background-color: $colour2 ; 
}
/* mobile * and middle * are provided for KHTML (Chrome, Android) compatibility*/



"; 

if ($_REQUEST['out']=="css") {
	$ISTEXT = 0 ;
		header('Content-type: text/css');
		echo $CSS;
		include ("css/default.css");
}	

if ($_REQUEST['out']=="iecss") {
	$ISTEXT = 0 ;
		header('Content-type: text/css');
		echo $CSS;
		include ("css/ie.css");
}	
?>
